<?php

/*
 * CMS_Db_Connection
 * @author Matias Chomicki
 * Database connection handler
 */

class CMS_Db_Connection
{

    private static $instance    = NULL;
    public $db                  = NULL;

    private function __construct()
    {
        $config = Zend_Registry::get('config');
        $params = array(
            'host'      => $config->Database->Host,
            'username'  => $config->Database->User,
            'password'  => $config->Database->Password,
            'dbname'    => $config->Database->Name
        );

        $this->db = Zend_Db::factory('Pdo_Mysql', $params);
    }

    public static function getInstance()
    {
        if (self::$instance == NULL)
            return self::$instance = new CMS_Db_Connection();

        return self::$instance;
    }

}